package base

import (
	"net"
	"net/rpc"
	"time"
)

type NetPacket struct {
	Addr string
	Body []byte
}

type NetCall struct {
	Method string
	Addr   string

	Args  interface{}
	Reply interface{}

	Status  chan uint8
	Timeout time.Duration
}

type NetTCP struct {
	Ln net.Listener

	out chan *NetCall

	pool     chan *rpc.Client
	poolsize int
}

type NetUDP struct {
	sock *net.UDPConn

	in  chan *NetPacket
	out chan *NetPacket

	// Handle incoming packets read from the socket
	handlers []NetUDPEventHandler
}

type NetUDPEventHandler func(*NetUDP, *NetPacket)
